<?php


namespace app\tickets\controller;


use think\Collection;
use think\Db;

class Config extends Collection
{

    /**
     * 门票配置
     * @author zhixuedong
     * @date 2021/1/30/030
     */
    public function newClick(){
        $config = Db::name("tickets_config")->find();
        $data['checkout_status'] = ($_POST['status']=='true')?1:2;
        if(empty($config)){
            Db::name("tickets_config")->insert($data);
        }else{
            Db::name("tickets_config")->where(['id'=>$config['id']])->update($data);
        }
    }

    /**
     * 门票类型
     * @author zhixuedong
     * @date 2021/2/5/005
     */
    public function updateType(){
        $config = Db::name("tickets_config")->find();
        $data['tickets_type'] = $_POST['tickets_type'];
        if(empty($config)){
            Db::name("tickets_config")->insert($data);
        }else{
            Db::name("tickets_config")->where(['id'=>$config['id']])->update($data);
        }
    }

    /**
     * 门票类型
     * @author zhixuedong
     * @date 2021/2/5/005
     */
    public function faceType(){
        $config = Db::name("tickets_config")->find();
        $data['face_type'] = ($_POST['face_type']=='true')?1:0;
        if(empty($config)){
            Db::name("tickets_config")->insert($data);
        }else{
            Db::name("tickets_config")->where(['id'=>$config['id']])->update($data);
        }
    }

    /**
     * 更新PDA配置
     * @author zhixuedong
     * @date 2021/2/27/027
     */
    public function updateConfig(){
        $config = Db::name("tickets_config")->find();
        $data = $_POST;
        $data['auto'] = empty($data['auto'])?"false":"true";
        if(empty($config)){
            Db::name("tickets_config")->insert($data);
        }else{
            Db::name("tickets_config")->where(['id'=>$config['id']])->update($data);
        }
        $black['msg'] = "操作成功";
        return $black;
    }

}